home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / clonecd / September 93.img / Archives / Decoration / Screensavers / Screen Savers / Darkness / darkInit.c < prev    next >
Text File  |  1990-06-24  |  2KB  |  93 lines

  1. /*
  2.     DARKINIT - the initialization routines to Dark,
  3.     a simple screen saver application for the 
  4.     "Darkness Multifinder Screen Saver System"
  5.         written by Lunarmobiscuit  Copyright 1989
  6. */
  7.  
  8. /* PROTOTYPES */
  9. void InitMacintosh(void);
  10. void SetUpMenus(void);
  11. int SetUpBigWindow(void);
  12. extern void update_big(void);
  13.  
  14.  
  15. extern MenuHandle appleMenu;
  16. extern WindowPtr bigWindow;
  17.  
  18. /* initialize mac managers */
  19. void InitMacintosh(void)
  20. {
  21.     MaxApplZone();
  22.     
  23.     InitGraf(&thePort);
  24.     InitFonts();
  25.     FlushEvents(everyEvent, 0);
  26.     InitWindows();
  27.     InitMenus();
  28.     TEInit();
  29.     InitDialogs(0L);
  30.     InitCursor();
  31.     PenNormal();
  32.     return;
  33. }
  34.  
  35.  
  36. /* create a "File" menu with a "Quit" item to keep Multifinder happy */
  37. void SetUpMenus(void)
  38. {
  39.     InsertMenu(appleMenu = GetMenu(0), 0);
  40.     DrawMenuBar();
  41.     return;
  42. }
  43.  
  44.  
  45. /* create a BIG window, covering the entire screen(s) and menu bar */
  46. int SetUpBigWindow(void)
  47. {
  48.     register int i;
  49.     EventRecord theEvent;
  50.     RgnHandle theGrayRgn,mBarRgn;
  51.     Rect theRect,mBarRect;
  52.     
  53.     /* make sure the window comes up on the top layer */
  54.     for (i=0;i<10;i++) EventAvail(everyEvent,&theEvent);
  55.     
  56.     /* First, determine the size for the window */
  57.     theGrayRgn = GetGrayRgn();
  58.     theRect = (**theGrayRgn).rgnBBox;
  59.      
  60.     /* Add on screenbits.bounds, as it includes the menu bar and grayrgn doesn't */
  61.     UnionRect(&theRect, &screenBits.bounds, &theRect);
  62.      
  63.     /* Open big window */
  64.     bigWindow = NewWindow(0L,&theRect,"\p",TRUE,0,-1L,FALSE,0L);
  65.     if (!bigWindow) return(FALSE);
  66.     SetPort(bigWindow);
  67.      
  68.     /* At this point, the new window is the correct size, but the visRgn
  69.     doesn't include the menu bar */
  70.     mBarRgn = NewRgn();
  71.     if (!mBarRgn) return(FALSE);
  72.     mBarRect = screenBits.bounds;
  73.     mBarRect.bottom = mBarRect.top + MBarHeight;
  74.     MBarHeight = 0; /* shrink the menu bar to avoid Multifinder's small icons */
  75.      
  76.     /* Screenbits is global, but visrgn is local */
  77.     GlobalToLocal(&topLeft(mBarRect));
  78.     GlobalToLocal(&botRight(mBarRect));
  79.      
  80.     /* Make region out of menu bar area */
  81.     RectRgn(mBarRgn, &mBarRect);
  82.      
  83.     /* Tack this onto the windows visRgn */
  84.     UnionRgn(bigWindow->visRgn, mBarRgn, bigWindow->visRgn);
  85.      
  86.     /* Get rid of the temp region */
  87.     DisposeRgn(mBarRgn);
  88.  
  89.      /* draw the window */
  90.     update_big();
  91.     return(TRUE);
  92. }
  93.